import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;
import java.awt.Toolkit;


public class Principal {

	private JFrame frmPrincipal;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Principal window = new Principal();
					window.frmPrincipal.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Principal() {
		try{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception e){
			System.out.println("Error setting native LAF: "+e);
		}
		initialize();
		Inteligencia.cargaInicial();
	}
	
	public JFrame getFramePrincipal() {
		return frmPrincipal;
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmPrincipal = new JFrame();
		frmPrincipal.setResizable(false);
		frmPrincipal.setIconImage(Toolkit.getDefaultToolkit().getImage(Principal.class.getResource("/imagenes/Logo_UNGS-recorte.png")));
		frmPrincipal.getContentPane().setBackground(Color.WHITE);
		frmPrincipal.setTitle("Akinator-Animal");
		frmPrincipal.setBounds(100, 100, 618, 350);
		frmPrincipal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmPrincipal.getContentPane().setLayout(null);
		
		JButton btnCancelar = new JButton("Cancelar");
		btnCancelar.setForeground(Color.RED);
		btnCancelar.setFont(new Font("DejaVu Serif", Font.BOLD, 16));
		btnCancelar.setBackground(new Color(255, 255, 255));
		btnCancelar.setBorder(null);
		btnCancelar.setBorderPainted(false);
		btnCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}
		});
		btnCancelar.setBounds(305, 216, 117, 42);
		frmPrincipal.getContentPane().add(btnCancelar);
		
		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon(Principal.class.getResource("/imagenes/akinator200x300.png")));
		lblNewLabel.setBounds(405, 20, 210, 289);
		frmPrincipal.getContentPane().add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Hola, Soy Akinator\n    \n");
		lblNewLabel_1.setForeground(Color.BLACK);
		lblNewLabel_1.setFont(new Font("DejaVu Serif", Font.BOLD, 24));
		lblNewLabel_1.setLabelFor(frmPrincipal);
		lblNewLabel_1.setBounds(91, 12, 302, 75);
		frmPrincipal.getContentPane().add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("Para empezar el juego, Haz click en Jugar\n");
		lblNewLabel_2.setForeground(Color.BLUE);
		lblNewLabel_2.setFont(new Font("DejaVu Serif", Font.BOLD, 16));
		lblNewLabel_2.setBounds(29, 81, 393, 81);
		frmPrincipal.getContentPane().add(lblNewLabel_2);
		
		JButton btnJugar = new JButton("Jugar");
		btnJugar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Juego juego= new Juego();
				juego.setVisible(true);
				// centrado respecto del padre
				juego.setLocationRelativeTo(frmPrincipal);
				frmPrincipal.setVisible(false);
			}
		});
		btnJugar.setBorderPainted(false);
		btnJugar.setIcon(new ImageIcon(Principal.class.getResource("/imagenes/Play-1-Hot-icon.png")));
		btnJugar.setBackground(new Color(255, 255, 255));
		btnJugar.setForeground(Color.GREEN);
		btnJugar.setBorder(null);
		btnJugar.setFont(new Font("DejaVu Serif", Font.BOLD, 22));
		btnJugar.setBounds(71, 195, 168, 81);
		frmPrincipal.getContentPane().add(btnJugar);
		
		JLabel lblFondo = new JLabel("");
		lblFondo.setIcon(new ImageIcon(Principal.class.getResource("/imagenes/desierto.png")));
		lblFondo.setBounds(0, 0, 618, 350);
		frmPrincipal.getContentPane().add(lblFondo);
		// frame al centro de la pantalla
		frmPrincipal.setLocationRelativeTo(null);
	}
}
